﻿@model SRF.Admin.Models.Department
@{
    Layout = "~/Views/Shared/_EditDialog.cshtml";  
}
@using SRF.UI.Html
@section header{
    <link href="@Url.Content("~/Scripts/zTree/css/zTreeStyle/zTreeStyle.css")" rel="stylesheet" type="text/css"/>
    <script src="@Url.Content("~/Scripts/zTree/js/jquery.ztree.all-3.5.min.js")" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">
        function onComplete() {
            $.dialog.close("ok");
        }
        function onDialogClose(msg) {
            $.ajaxSubmit();
        } 
    </script>
}
@using (Ajax.BeginForm("edit", null, new AjaxOptions() { HttpMethod = "Post", OnComplete = "onComplete" }, new { @class = "form-horizontal" }))
{   
    @Html.HiddenFor(m => m.Id)
    <table>
        <tr>
            <td colspan="2">
                <label class="control-label" for="Name">
                    名称:</label>
                @Html.TextBoxFor(m => m.Name)
            </td>
        </tr>
        <tr>
            <td style="width: 300px">
                <label class="control-label" for="ParentId">
                    上级部门:</label>
                @Html.TreeSelectorFor(m => m.ParentId, ViewBag.DepartmentList as IList<SRF.Admin.Models.Department>,
                (m) => m.Id, (m) => m.ParentId, (m) => m.Name, Model == null ? null : Model.Id)

                @*         @{ 
               var html= Html.TreeSelector<SRF.Admin.Models.Department>("ParentId", Model.ParentId,
                    ViewBag.DepartmentList as IList<SRF.Admin.Models.Department>,
                    (m) => m.Id, (m) => m.ParentId, (m) => m.Name, Model == null ? null : Model.Id).ToHtmlString(); 
                @Html.Raw(html)
              }*@
            </td>
            <td>
                <label class="control-label" for="Rank">
                    排序:</label>
                @Html.TextBoxFor(m => m.Rank)
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <label class="control-label" for="Remark">
                    备注:</label>
                @Html.TextBoxFor(m => m.Remark, new { @class = "textbox-larger" })
            </td>
        </tr>
    </table>
}